#include "widget.h"
#include "ui_widget.h"
#include <QFileInfo>
#include <QFileDialog>
#include <QDebug>
#include <QDateTime>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QString path = QFileDialog::getOpenFileName(this,"打开文件","C:\\Users\\14725\\Desktop");
    QFileInfo fileinfo(path);

    qDebug() << "文件名：" << fileinfo.fileName().toUtf8().data();
    qDebug() << "后缀名：" << fileinfo.suffix().toUtf8().data();
    qDebug() << "文件大小：" << fileinfo.size();
    qDebug() << "文件路径：" << fileinfo.path().toUtf8().data();
    qDebug() << "是否为文件：" << fileinfo.isFile();
    qDebug() << "是否为目录：" << fileinfo.isDir();

    QDateTime time1 = fileinfo.fileTime(QFileDevice::FileBirthTime);
    qDebug() << "创建时间：" << time1.toString("yyyy-MM-dd hh:mm:ss").toUtf8().data();

    QDateTime time2 = fileinfo.lastModified();
    qDebug() << "上次修改时间：" << time2.toString("yyyy-MM-dd hh:mm:ss").toUtf8().data();
}

Widget::~Widget()
{
    delete ui;
}

